package javatest3.ForWhileTest.test3;

import java.util.Random;
import java.util.Scanner;

public class method2 {
    public static void main(String[] args) {
        Random random = new Random();
        int truenum = random.nextInt(10)+1;
        for (int flag=1;flag<=3;flag++){
            Scanner scanner = new Scanner(System.in);
            int guessnum = scanner.nextInt();
            if (guessnum<truenum){
                System.out.println("猜小了");

            }
            if (guessnum>truenum){
                System.out.println("猜大了");

            }
            if (guessnum==truenum){
                System.out.println("猜对了");
                break;
            }
            if (flag<3){
                System.out.println("你还剩"+(3-flag)+"次");
            }else {
                System.out.println("你的次数用完了");
            }
            }

        }
        }




